<template>
  <div class="customer-buss-form-manage" v-loading="loading" element-loading-text="加载中。。。">
    <div>
      <el-card class='type-info-box-card'>
        <el-form ref='form' :model='form' size='mini' label-position='top'>
          <el-row :gutter="10">
            <el-col :lg="4" :md="6" >
            <el-form-item label="机构" prop="AGENTDEP">
              <select-tree :branch="form.BRANCHNAME" @getBranchName="getBranch">
              </select-tree>
            </el-form-item>
          </el-col>
            <el-col :md="6" :lg="4">
              <el-form-item label='坐席工号' class='typeInfo-el-form-item' prop='AGENTID'>
                <el-input v-model="form.AGENTID" placeholder="请输入坐席工号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :md="6" :lg="4">
              <el-form-item label='班' class='typeInfo-el-form-item' prop='AGENTCLASS'>
                <el-select v-model="form.AGENTCLASS" filterable placeholder="请选择班" @change="changeClass" clearable>
                  <el-option v-for="item in STeamTypeList" :value="item.TEAMID" :key="item.index"
                    :label="item.TEAMID+'-'+item.TEAMNAME">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :md="6" :lg="4">
              <el-form-item label='组' class='typeInfo-el-form-item' prop='AGENTID'>
                <el-select v-model="form.AGENTTEAM" filterable placeholder="请选择班" :disabled="form.AGENTCLASS==''">
                  <el-option v-for="item in teamOption" :value="item.TEAMID" :key="item.TEAMID"
                    :label="item.TEAMID+'-'+item.TEAMNAME">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :md="6" :lg="4">
              <el-form-item label="角色" prop="AGENTROLE">
                <el-select v-model="form.AGENTROLE" filterable placeholder="请选择角色">
                  <el-option v-for="item in AGENTROLELIST" :key="item.value" :label="item.name" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :md="6" :lg="4">
              <el-form-item label="坐席状态" prop="AGENTSTATUS">
                <!-- <el-select v-model="form.AGENTSTATUS" filterable placeholder="请选择坐席状态">
                  <el-option v-for="item in AGENTSTATUSLIST" :key="item.value" :label="item.name" :value="item.value">
                  </el-option>
                </el-select> -->
                <el-select v-model="form.STAFSTS" filterable placeholder="请选择坐席状态">
                  <el-option v-for="item in STAFSTSLIST" :key="item.value" :label="item.name" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <!-- <el-col :md="6" :lg="4">
              <el-form-item label="性别" prop="AGENTSEX">
                <el-select v-model="form.AGENTSEX" filterable placeholder="请选择性别">
                  <el-option v-for="item in AGENTSEXLIST" :key="item.value" :label="item.name" :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col> -->
            <el-col :md="6" :lg="6">
              <el-button type='primary' size='mini' icon='el-icon-search' @click="agentQuery">查询</el-button>
              <el-button type='warning' size='mini' icon='el-icon-refresh' @click="clearForm('form')">重置</el-button>
            </el-col>
          </el-row>
        </el-form>
      </el-card>
      <el-card class='type-info-bottom'>
        <el-row :gutter="10">
          <el-col :md="24" :lg="20">
            <el-button type="primary" size="mini" v-if="btnPermission('Button_User_Add')" icon='el-icon-plus' @click="add">新增</el-button>
            <el-button type="primary" size="mini" v-if="btnPermission('Button_User_Edit')" icon='el-icon-edit' :disabled="currentRow.length!=1" @click="update">修改</el-button>
            <el-button type="danger" size="mini"  v-if="btnPermission('Button_User_Edit')" icon='el-icon-delete' :disabled="currentRow.length!=1" @click="delAgent">删除</el-button>
            <el-button type="primary" size="mini" icon='el-icon-more'  :disabled="currentRow.length!=1" @click="detail"  v-if="btnPermission('Button_User_Detail')">查看详情</el-button>
            <el-button type="success" @click="downloadDemo" v-if="btnPermission('Button_User_Edit')" icon="el-icon-download" size='mini'>模板下载</el-button>
            <el-button type="success" @click="openInsert" v-if="btnPermission('Button_User_Edit')" icon="el-icon-upload2" size='mini'>批量上传</el-button>
          </el-col>
          <!-- <el-col :lg="2" :md="3" v-if="btnPermission('Button_User_Add')">
            <el-button type="primary" size="mini" icon='el-icon-plus' @click="add">新增</el-button>
          </el-col>
          <el-col :lg="2" :md="3" v-if="btnPermission('Button_User_Edit')">
            <el-button type="primary" size="mini" icon='el-icon-edit' :disabled="currentRow.length!=1" @click="update">
              修改</el-button>
          </el-col>
          <el-col :lg="2" :md="3" v-if="btnPermission('Button_User_Edit')">
            <el-button type="danger" size="mini" icon='el-icon-delete' :disabled="currentRow.length<1"
              @click="delAgent" >删除</el-button>
          </el-col> -->
          <!-- <el-col :lg="2" :md="3" v-if="btnPermission('Button_Info_Subscribe')">
          <el-button type="primary"
            size="mini" :disabled="currentRow.length!=1" icon="el-icon-circle-check" @click="Order">订阅</el-button>
        </el-col> -->
          <!-- <el-col :lg="2" :md="3" v-if="btnPermission('Button_User_All_Subscribe')">
          <el-button type="primary" size="mini" @click="OrderAll">全订阅</el-button>
        </el-col> -->
          <!-- <el-col :lg="3" :md="4" v-if="btnPermission('Button_Info_CancelSubscribe')">
          <el-button type="danger"
            size="mini" :disabled="currentRow.length!=1" icon="el-icon-circle-close" @click="CancelOrder">取消订阅</el-button>
        </el-col>         -->
          <!-- <el-col :lg="3" :md="4" v-if="btnPermission('Button_User_Detail')">
            <el-button type="primary" size="mini" icon='el-icon-more' :disabled="currentRow.length!=1" @click="detail">
              查看详情</el-button>
          </el-col>
          <el-col :lg="3" :md="4" v-if="btnPermission('Button_User_Edit')">
            <el-button type="primary" @click="downloadDemo" icon="el-icon-download" size='mini'>模板下载</el-button>
          </el-col>
          <el-col :lg="3" :md="4" v-if="btnPermission('Button_User_Edit')">
            <el-button type="primary" @click="openInsert" icon="el-icon-download" size='mini'>批量上传</el-button>
          </el-col> -->
          <!-- <el-col :lg="3" :md="4" v-if="btnPermission('Button_Info_Subscribe')">
          <el-button type="primary"
            size="mini" :disabled="currentRow.length!=1" icon="el-icon-circle-check" @click="Reset">坐席状态重置</el-button>
        </el-col> -->
        </el-row>
        <!-- 若要使用动态表头 建议在data中单列出table的header内容 在data中监听不到 -->
        <el-table border ref="tableData" :data='tableData' class="tableMarginTop"
          @selection-change="handleCurrentChange" header-row-class-name="tableHeaderClass">
          <!-- 这里的prop按照返回的字段去更新 -->
          <el-table-column type="selection" width="40px"></el-table-column>
          <el-table-column prop='AGENTID' label='坐席工号' width="100"></el-table-column>
          <el-table-column prop='AGENTNAME' label='姓名' width="100"></el-table-column>
          <el-table-column prop='AGENTDEP' label='机构' ></el-table-column>
          <el-table-column prop='AGENTCLASS' label='班' :formatter="dataFormat"></el-table-column>
          <el-table-column prop='AGENTTEAM' label='组名' :formatter="dataFormat"></el-table-column>
          <el-table-column prop='AGENTROLE' label='角色' width="100" :formatter="dataFormat"></el-table-column>
          <el-table-column prop='AGENTLEVEL' label='坐席等级' :formatter="dataFormat"></el-table-column>
          <el-table-column prop='MULTITYPE' label='受理渠道' width="120" :formatter="dataFormat"></el-table-column>
          <el-table-column prop='STAFSTS' label='人员状态' :formatter="dataFormat"></el-table-column>
          <el-table-column prop='TELPHONE' label='联系方式' width="120"></el-table-column>
          <el-table-column prop='EMAIL' label='邮箱' width="120"></el-table-column>
          <el-table-column prop='AGENTSEX' label='性别' :formatter="dataFormat"></el-table-column>
          <el-table-column prop='LOGINFLG' label='登录方式' :formatter="dataFormat"></el-table-column>
        </el-table>
        <div style="text-align:right;margin-top:20px;">
          <el-pagination background @current-change="changePage" :current-page="currentPage" :page-size="pageSize"
            layout="total, prev, pager, next, jumper" :total="tableTotal">
          </el-pagination>
        </div>
      </el-card>
      <!-- 弹窗 -->
      <keep-alive>
        <component :is="dialogList.excelToJson" :option="dialogExcelOptions" @refreshTable1="agentQuery"></component>
      </keep-alive>
        <component :is="dialogList.addDialog" :option="dialogOptions" @refreshTable="agentQuery"></component>
    </div>
  </div>
</template>
<script>
  import addDialog from "./dialog/addDialog";
  import requestYg from "@/common/utils/requestYg";
  import getGlobalParams from "@/common/utils/getGlobalParams";
  // 班组接口
  import teamManage from "@/message/seat-manage/setaTeam/teamManage";
  // 坐席维护接口
  import agentManage from "@/message/seat-manage/SeatInfoManage/agentManage";
  //模板下载
  import download from "@/message/seat-manage/SeatInfoManage/templateDownload"
  //批量上传
  import excelToJson from "./dialog/excelToJson";
import selectTree from "@/components/selectTree5/"
  // import order from "@/message/seat-manage/SeatInfoManage/order";
  // import cancelorder from "@/message/seat-manage/SeatInfoManage/cancelorder";
  // import orderall from "@/message/seat-manage/SeatInfoManage/orderall";
  // import reset from "@/message/seat-manage/SeatInfoManage/reset";
  // import query1 from "@/message/seat-manage/setaTeam/query";
  export default {
    components: {
      selectTree
    },
    data() {
      return {
        fileDownUrl: '',
        'mediaList': {
          '00': '电话',
          '01': '视频',
          '02': '文字',
        },
        loading: false,
        tableData: [],
        tableTotal: 0,
        currentRow: [],
        deptMap: {},
        currentPage: 1,
        pageSize: getGlobalParams.get("PageSize"),
        form: {
          AGENTDEP: this.$store.getters.BranchNum,
          BRANCHNAME: this.$store.getters.BranchName,
          AGENTTEAM: '', //组
          STAFSTS: '', //坐席状态
          // AGENTDEP: '', //机构
          AGENTID: "",
          AGENTROLE: "",
          AGENTSTATUS: "",
          AGENTSEX: "",
          AGENTCLASS: '',//班
        },
        STeamTypeList: [], //班
        teamOption: [], //组
        STAFSTSLIST: [{
            name: '试用',
            value: '01'
          },
          {
            name: '正式上岗',
            value: '02'
          },
        ],
        "AGENTROLE": {
          "01": "01-普通坐席",
          "02": "02-组长",
          "03": "03-班长",
          // "04": "04-坐席主管",
          // "05": "05-坐席经理",
          // "06": "06-质检员",
          // "07": "07-质检主管",
          // "08": "08-培训师",
          // "09": "09-培训主管",
          // "10": "10-排班师",
          // "11": "11-排班主管",
          // "12": "12-知识库普通用户",
          // "13": "13-知识库管理员"
        },
        "AGENTLEVEL": {
          "1": "1-一星",
          "2": "2-二星",
          "3": "3-三星",
          "4": "4-四星",
          "5": "5-五星",
        },
        "LOGINFLG": {
          "1": "1-密码",
          "0": "0-指纹",
        },
        "AGENTSEX": {
          "1": "1-男",
          "2": "2-女",
        },
        "STAFSTS": {
          "01": "试用",
          "02": "正式上岗"
        },
        "ENGLEVEL": {
          "3": "3-三级",
          "4": "4-四级",
          "6": "6-六级"
        },
        "AGENTSTATUS": {
          "0": "0-未登录",
          "1": "1-登录",
          "2": "2-签入",
          "3": "3-签出",
          "5": "5-示忙",
          "6": "6-小休",
        },
        // "AGENTDEP": {
        //   "001": "金科",
        //   "002": "睿银"
        // },
        dialogExcelOptions: {
        isShow: false
      },
        AGENTROLELIST: [{
            name: "普通坐席",
            value: "01"
          },
          {
            name: "组长",
            value: "02"
          },
          {
            name: "班长",
            value: "03"
          },
          // {name: "坐席主管", value: "04"},
          // {name: "坐席经理", value: "05"},
          // {name: "质检员", value: "06"},
          // {name: "质检主管", value: "07"},
          // {name: "培训师", value: "08"},
          // {name: "培训主管", value: "09"},
          // {name: "排班师", value: "10"},
          // {name: "排班主管", value: "11"},
          // {name: "知识库普通用户", value: "12"},
          // {name: "知识库管理员", value: "13"}
        ],
        AGENTSTATUSLIST: [{
            name: "未登录",
            value: "0"
          },
          {
            name: "登录",
            value: "1"
          },
          {
            name: "签入",
            value: "2"
          },
          {
            name: "签出",
            value: "3"
          },
          {
            name: "示忙",
            value: "5"
          },
          {
            name: "小休",
            value: "6"
          }
        ],
        AGENTSEXLIST: [{
            name: "男",
            value: "1"
          },
          {
            name: "女",
            value: "2"
          }
        ],
        dialogList: {
          addDialog,
          excelToJson
        },
        dialogOptions: {
          isShow: false
        }
      }
    },
    mounted() {
      this.fileDownUrl = getGlobalParams.get("FileDownloadAddress");
      this.squery(); //查询班
      this.teamQuery();
      this.agentQuery()
    },
    methods: {
      getBranch(data) {
        this.form.AGENTDEP = data.BRANCHNO
        this.form.BRANCHNAME = data.BRANCHNAME
      },
      // 下载模板
      async downloadDemo() {
        let resBody = new download()
        let response = await requestYg(resBody);
        if (response.SYS_HEAD.ReturnCode == "000000") {
          let res = response.BODY
          let FilePath = res.FilePath
          let name = res.FileName
          this.downloadFile(this.fileDownUrl + FilePath + '/' + name)
        } else {
          this.$message({
            type: "error",
            message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
          })
        }
      },
      // 过滤渠道
      mediaFormat(str) {
        let value = []
        let arr = str.split('|')
        arr.forEach(item => {
          value.push(this.mediaList[item])
        })
        return value.join(',')
      },
      // 打开批量上传的Dialog
      openInsert(){
        this.dialogExcelOptions.isShow = true;
      },
      //批量删除
      // delAgent() {
      //   this.$confirm('此操作将删除, 是否继续?', '提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning'
      //   }).then(async () => {
      //     let resBody = new agentManage()
      //     let id = []
      //     this.currentRow.forEach(item => {
      //       id.push(item.AGENTID)
      //     })
      //     resBody.data.AGENTIDS = id.join(',')
      //     resBody.data.OPERATION = '3'
      //     let response = await requestYg(resBody);
      //     if (response.SYS_HEAD.ReturnCode == "000000") {
      //       this.$message({
      //         type: "success",
      //         message: "删除成功"
      //       });
      //       this.agentQuery()
      //     } else {
      //       this.$message({
      //         type: "error",
      //         message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
      //       })
      //     }
      //     this.$message({
      //       type: 'success',
      //       message: '删除成功!'
      //     });
      //   }).catch(() => {
      //     this.$message({
      //       type: 'info',
      //       message: '已取消删除'
      //     });
      //   });
      // },
      //删除
      delAgent() {
        this.$confirm('此操作将删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(async () => {
          let resBody = new agentManage()
          resBody.data.AGENTID = this.currentRow[0].AGENTID
          resBody.data.OPERATION = '3'
          let response = await requestYg(resBody);
          if (response.SYS_HEAD.ReturnCode == "000000") {
            this.$message({
              type: "success",
              message: "删除成功"
            });
            this.agentQuery()
          } else {
            this.$message({
              type: "error",
              message: "请求失败，错误码:" + response.SYS_HEAD.ReturnCode + "，错误信息：" + response.SYS_HEAD.ReturnMessage
            })
          }
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      // 查询班
      squery() {
        this.loading = true;
        let resBody = new teamManage();
        resBody.data.OPERATION = "4";
        resBody.data.TEAMTYPE = "1";
        requestYg(resBody)
          .then(response => {
            if (response.SYS_HEAD.ReturnCode === "000000") {
              this.STeamTypeList = response.RSP_BODY.struct;
              for (let i = 0; i < this.STeamTypeList.length; i++) {
                const element = this.STeamTypeList[i];
                this.deptMap[element.TEAMID] = element.TEAMNAME;
              }
              this.agentQuery();
            } else {
              this.$message({
                type: "error",
                message: "请求失败，错误码: " + response.SYS_HEAD.ReturnCode + ",错误信息: " + response.SYS_HEAD.ReturnMessage
              });
              this.STeamTypeList = [];
            }
          })
          .catch(error => {
            this.loading = false;
          })
      },
      // 查询组
      async teamQuery() {
        //debugger
        let resBody = new teamManage();
        resBody.data.OPERATION = '4'
        resBody.data.TEAMTYPE = '2'
        resBody.data.PAGEFLAG = 4
        resBody.data.CURRPAGE = 1
        resBody.data.PAGEROWNUM = 100
        resBody.data.HTEAMID = this.form.AGENTCLASS
        let response = await requestYg(resBody);
        if (response.SYS_HEAD.ReturnCode === "000000") {
          this.teamOption = response.RSP_BODY.struct
          for (let i = 0; i < this.teamOption.length; i++) {
            const element = this.teamOption[i];
            this.deptMap[element.TEAMID] = element.TEAMNAME;
          }
        } else {
          this.$message({
            type: "error",
            message: '该班下没有对应组'
          });
          this.teamOption = []
          this.form.GENTTEAM = ''
        }
      },
      // 切换班
      changeClass() {
        this.form.AGENTTEAM = ''
        this.teamQuery()
      },
      dataFormat(row, column) {
        if (column.property == "AGENTLEVEL")
          return this.AGENTLEVEL[row[column.property]];
        if (column.property == "LOGINFLG")
          return this.LOGINFLG[row[column.property]];
        if (column.property == "AGENTSEX")
          return this.AGENTSEX[row[column.property]];
        if (column.property == "ENGLEVEL")
          return this.ENGLEVEL[row[column.property]];
        if (column.property == "AGENTSTATUS")
          return this.AGENTSTATUS[row[column.property]];
        if (column.property == "AGENTCLASS")
          return this.deptMap[row[column.property]];
        if (column.property == "AGENTROLE")
          return this.AGENTROLE[row[column.property]];
        if (column.property == "AGENTTEAM")
          return this.deptMap[row[column.property]];
        if (column.property == "STAFSTS")
          return this.STAFSTS[row[column.property]];
        if (column.property == "MULTITYPE")
          return this.mediaFormat(row[column.property]);
      },
      // 取消订阅
      // CancelOrder(){
      //   let resBody = new cancelorder();
      //   console.log("点击了取消订阅");
      //   resBody.data.AGENTID = this.currentRow[0].AGENTID;
      //   console.log("取消订阅发送的resbody",resBody.data);
      //   requestYg(resBody)
      //   .then(response => {
      //     console.log("坐席取消订阅返回的response",response);
      //     if(response.SYS_HEAD.ReturnCode === "000000"){
      //       this.$aui.message.show({
      //         type: "success",
      //         message: "取消订阅成功！"
      //       });
      //     } else {
      //       this.$aui.message.show({
      //         type: "error",
      //         message: "请求失败，错误码: " +
      //           response.SYS_HEAD.ReturnCode +
      //           ", 错误信息: " + response.SYS_HEAD.ReturnMessage
      //       });
      //     }
      //   })
      //   .catch(error => {
      //   });
      // },
      // OrderAll(){//订阅
      //    let resBody = new orderall();
      //   request1(resBody)
      //   .then(response => {
      //     if(response.SYS_HEAD.ReturnCode === "000000"){
      //       this.$aui.message.show({
      //         type: "success",
      //         message: "全订阅成功！"
      //       });
      //     } else {
      //       this.$aui.message.show({
      //         type: "error",
      //         message: "请求失败，错误码: " +
      //           response.SYS_HEAD.ReturnCode +
      //           ", 错误信息: " + response.SYS_HEAD.ReturnMessage
      //       });
      //     }
      //   })
      //   .catch(error => {
      //   });
      // },
      // 订阅
      // Order(){//订阅
      //    let resBody = new order();
      //   //  console.log("点击了订阅");
      //   resBody.data.AGENTID = this.currentRow[0].AGENTID;
      //    console.log("订阅发送的resbody",resBody.data);
      //   requestYg(resBody)
      //   .then(response => {
      //       console.log("订阅返回的response",response);
      //     if(response.SYS_HEAD.ReturnCode === "000000"){
      //        this.$aui.message.show({
      //         type: "success",
      //         message: "订阅成功！"
      //       });
      //     } else {
      //       this.$aui.message.show({
      //         type: "error",
      //         message: "请求失败，错误码: " +
      //           response.SYS_HEAD.ReturnCode +
      //           ", 错误信息: " + response.SYS_HEAD.ReturnMessage
      //       });
      //     }
      //   })
      //   .catch(error => {
      //   });
      // },
      // Reset(){//坐席重置
      //    let resBody = new reset();
      //   resBody.data.AGENTID = this.currentRow[0].AGENTID; 
      //   request1(resBody)
      //   .then(response => {
      //     if(response.SYS_HEAD.ReturnCode === "000000"){
      //        this.$aui.message.show({
      //         type: "success",
      //         message: "坐席重置成功！"
      //       });
      //       this.query();
      //     } else {
      //       this.$aui.message.show({
      //         type: "error",
      //         message: "请求失败，错误码: " +
      //           response.SYS_HEAD.ReturnCode +
      //           ", 错误信息: " + response.SYS_HEAD.ReturnMessage
      //       });
      //     }
      //   })
      //   .catch(error => {
      //   });
      // },
      add() {
        this.dialogOptions.isShow = true;
        this.dialogOptions.isDetail = false;
        this.dialogOptions.isChecked = false;
        this.dialogOptions.title = "坐席人员新增";
        this.dialogOptions.log = "1";
        this.dialogOptions.showButton = true;
        this.dialogOptions.showPass = true;
      },
      update() {
        this.dialogOptions.isShow = true;
        this.dialogOptions.isDetail = false;
        this.dialogOptions.isChecked = true;
        this.dialogOptions.title = "坐席人员修改";
        this.currentRow[0].BRANCHNAME = this.form.BRANCHNAME
        this.dialogOptions.currentRow = this.currentRow[0];
        this.dialogOptions.log = "2";
        this.dialogOptions.showButton = true;
        this.dialogOptions.showPass = false;
      },
      detail() {
        this.dialogOptions.isShow = true;
        this.dialogOptions.isChecked = true;
        this.dialogOptions.isDetail = true;
        this.dialogOptions.title = "坐席人员详情";
        this.currentRow[0].BRANCHNAME = this.form.BRANCHNAME
        this.dialogOptions.currentRow = this.currentRow[0];
        this.dialogOptions.log = "3";
        this.dialogOptions.showButton = false;
        this.dialogOptions.showPass = true;
      },
      // 查询坐席
      async agentQuery() {
        this.loading = false;
        let resBody = new agentManage();
        resBody.data.OPERATION = '4'
        resBody.data.AGENTID = this.form.AGENTID;
        resBody.data.AGENTROLE = this.form.AGENTROLE;
        resBody.data.STAFSTS = this.form.STAFSTS;
        resBody.data.AGENTDEP = this.form.AGENTDEP;
        resBody.data.AGENTCLASS = this.form.AGENTCLASS;
        resBody.data.AGENTTEAM = this.form.AGENTTEAM;
        resBody.data.PAGEFLAG = 4;
        resBody.data.PAGEROWNUM = this.pageSize;
        resBody.data.CURRPAGE = this.currentPage;
        requestYg(resBody)
          .then(response => {
            if (response.SYS_HEAD.ReturnCode === "000000") {
              this.tableData = response.RSP_BODY.struct;
              this.tableTotal = response.RSP_BODY.TOTALROWNUM;
            } else {
              this.$message({
                type: "error",
                message: "请求失败，错误码: " +
                  response.SYS_HEAD.ReturnCode +
                  ", 错误信息: " + response.SYS_HEAD.ReturnMessage
              });
              this.tableData = [];
              this.tableTotal = 0;
            }
            this.loading = false;
          })
          .catch(error => {
            this.loading = false;
          });
      },
      clearForm(item) {
        this.$refs["" + item].resetFields();
        this.form.AGENTTEAM = ''
        this.form.AGENTCLASS = ''
      },
      handleCurrentChange(val) {
        this.currentRow = val;
      },
      changePage(val) {
        this.currentPage = val;
        this.agentQuery();
      }
    }
  }

</script>
